<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
<meta name="decorator" content="moduleList" />
<link rel="stylesheet"
	href="${staticPath}/lib/ztree/3.5/css/zTreeStyle/zTreeStyle.css"
	type="text/css">
<script src="${staticPath}/js/jquery-dialog.js" type="text/javascript"></script>
<script src="${staticPath}/lib/ztree/3.5/js/jquery.ztree.all-3.5.js"
	type="text/javascript"></script>
<script type="text/javascript" src="${staticPath}/js/contract_list.js">
	
</script>
<script type="text/javascript">
	var storeId1 = '${brandPositionLog.storeId}';
	function cleanWhere() {
		$("#areaId").val("");
		$("#area").val("");
		$("#storeId").empty();
		$("#storeId").append("<option value='' >---请选择---</option>");
		$("#store").val("");
		$("#floorId").empty();
		$("#floorId").append("<option value='' >---请选择---</option>");
		$("#floor").val("");
	}

	function openModal() {
		var index_list = new Array();
		$('input[name=\"checke\"]:checked').each(function() {
			index_list.push($(this).attr("index"));
		});
		if (index_list.length == 0) {
			$.jBox.tip("请先勾选需要提交的数据！", "${error}", {
				persistent : true,
				opacity : 0
			});
			return;
		}
		if (index_list.length > 1) {
			for (var i = 0; i < index_list.length; i++) {
				var supplierCname = $("#supplierCname_lab" + index_list[0])
						.text();
				var shopName = $("#shopName_lab" + index_list[0]).text();
				var floorName = $("#floorName_lab" + index_list[0]).text();

				var supplierCname2 = $("#supplierCname_lab" + index_list[i])
						.text();
				var shopName2 = $("#shopName_lab" + index_list[i]).text();
				var floorName2 = $("#floorName_lab" + index_list[i]).text();

				if (supplierCname != supplierCname2) {
					top.$.jBox.tip('必须为同一供应商才能意向洽谈', 'warning');
					return;
				} else if (shopName != shopName2) {
					top.$.jBox.tip('必须为同一门店才能意向洽谈', 'warning');
					return;
				} else if (floorName != floorName2) {
					top.$.jBox.tip('必须为同一门店才能意向洽谈', 'warning');
					return;
				}
			}
		}
		$("#contractTypeMoadl").modal()
	}

	function brandAdd() {
		var check_id = "";
		$('input[name=\"checke\"]:checked').each(function() {
			check_id += $(this).val() + ",";
		});
		var contractType = $("#type").val();
		if (contractType == "") {
			$.jBox.tip("请选择合同类型！", "${error}", {
				persistent : true,
				opacity : 0
			});
			return;
		}
		$("#ok").attr("data-dismiss", "modal");
		var mainContractNo = $("#mainContractNo").val();
		window.open('${contextPath}/biz/contract/assrecord/brandAdd?strIds='
				+ check_id + "&contractType=" + contractType + "&mainContractNo="+mainContractNo
				+ "&navId=${navId}", '_self');
	}
	
	
	function showDiv(){
		var type = $("#type").val();
		if(type == 'Z600'){
			$("#mainContractNoDiv").show();				
		}else{
			$("#mainContractNoDiv").hide();
		}
	}
</script>
</head>
<body>
	<form:form name="listForm" id="brandPositionLogForm"
		action="${contextPath}/biz/brand/brandPositionLog/purList?navId=${navId}"
		modelAttribute="brandPositionLog" method="post" class="form-inline"
		role="form">
		<input type="hidden" name="deleteIds">
		<input type="hidden" id="contractType" value="brandPositionLog">
		<ol class="breadcrumb map_1">
			<li><a href="${contextPath}/index">首页</a></li>
			<li><a
				href="${contextPath}/biz/intent/intAssociated/list?navId=${navId}">招商合约</a></li>
			<li class="active">招商信息发布</li>
		</ol>
		<div class="o-l-search-builder f_1">
			<div id="statement-search-builder" class="collapse"
				style="height: auto;">
				<div class="f_3">
					<div class="form-group col-sm-6">
						<label for="inputtext3" class="col-sm-3 control-label f_4">区域：</label>
						<div class="col-sm-9 f_6">
							<div class="input-group">
								<input type="hidden" id="areaId" name="areaId" value="${brandPositionLog.areaId}"/> <input
									type="text" class="f_5" id="area" readonly="readonly"
									name="area" value="${brandPositionLog.area}"> <span class="input-group-addon f_time"><a
									id="clean" href="#"><i class="glyphicon glyphicon-remove"></i></a></span>
									<span class="input-group-btn">
									<button class="btn btn-default btn_3" id="areaBtn" type="button">选择</button>
									</span>
							</div>
						</div>
					</div>
					<div class="form-group col-sm-6">
						<label for="store" class="col-sm-3 control-label f_4">门店名：</label>
						<div class="col-sm-9 f_6">
							<select class="f_5" id="storeId" name="storeId">
								<option value="">---请选择---</option>
								<c:if test="${not empty brandPositionLog.storeId}">
									<option value="${brandPositionLog.storeId}" selected="selected">${brandPositionLog.store}</option>
								</c:if>
								
							</select> <input type="hidden" id="store" name="store"
								value="${brandPositionLog.store}" />
						</div>
					</div>
				</div>
				<div class="f_3">

					<div class="form-group col-sm-6">
						<label for="floorId" class="col-sm-3 control-label f_7">楼层：</label>
						<div class="col-sm-9 f_6">
							<select class="f_5" id="floorId" name="floorId">
								<option value="">---请选择---</option>
								<c:if test="${not empty brandPositionLog.floorId}">
									<option value="${brandPositionLog.floorId}" selected="selected">${brandPositionLog.floor}</option>
								</c:if>
							</select> <input type="hidden" id="floor" name="floor" />
						</div>
					</div>
					
					<div class="form-group col-sm-6">
						<label for="floorId" class="col-sm-3 control-label f_7">状态：</label>
						<div class="col-sm-9 f_6">
							<ossp:select dictType="brandPositionLog" class_="f_5" defaultSelected="10" value="${brandPositionLog.status}" name="status"></ossp:select>
						</div>
					</div>
					
				</div>
				
				<div class="f_3">
					<div class="form-group col-sm-6">
						<label for="floorId" class="col-sm-3 control-label f_7">供应商编码：</label>
						<div class="col-sm-9 f_6">
							<input id="title" type="text" name="supplier.supplierNo"  class="f_5" value="${brandPositionLog.supplier.supplierNo}" />
						</div>
					</div>
					
						<div class="form-group col-sm-6">
						<label for="floorId" class="col-sm-3 control-label f_7">供应商名称：</label>
						<div class="col-sm-9 f_6">
							<input id="title" type="text" name="supplier.cname"  class="f_5" value="${brandPositionLog.supplier.cname}" />
						</div>
					</div>
					
				</div>
				
				<div class="f_3">
					<div class="form-group col-sm-6">
						<label for="floorId" class="col-sm-3 control-label f_7">品牌编码：</label>
						<div class="col-sm-9 f_6">
							<input id="title" type="text" name="brandCate.brandNo"  class="f_5" value="${brandPositionLog.brandCate.brandNo}" />
						</div>
					</div>
					
						<div class="form-group col-sm-6">
						<label for="floorId" class="col-sm-3 control-label f_7">品牌名称：</label>
						<div class="col-sm-9 f_6">
							<input id="title" type="text" name="brandCate.brandCname"  class="f_5" value="${brandPositionLog.brandCate.brandCname}" />
						</div>
					</div>
					
				</div>
			</div>
			<div class="f_8">
				<div class="f_2">
					<div class="col-sm-4 f_6">
						<input id="title" type="text" name="title" placeholder="招商标题"
							class="f_5" value="" />
					</div>
					<button type="button" id="queryBtn" class="btn btn-warning btn_1">查&nbsp&nbsp;询</button>
					<button type="button" id="clean" onclick="cleanWhere()"
						class="btn btn-warning btn_1">重&nbsp&nbsp;置</button>
				</div>
			</div>
			<div class="o-l-chevron-down">
				<a href="#" class="btn btn-default collapsed" data-toggle="collapse"
					data-target="#statement-search-builder" id="chevronDownBtn"
					role="button"><span id="glyphiconspan"
					class="glyphicon glyphicon-chevron-down"></span></a>
			</div>
		</div>

		<div class="o-l-search-builder f_1">
		<shiro:hasPermission name="com.maoye.ossp.biz.contract.BrandPositionlog:brandAdd">
			<button type="button" class="btn btn-info btn_3 btn_right" onclick="openModal()">发起&nbsp;洽谈</button>
		</shiro:hasPermission>
		</div>
		<tags:message content="${message}" />
		<div class="o-l-search-builder f_9">
			<table
				class="table table-striped table-hover o-l-table table-bordered"
				id="table1">
				<thead class="t_1">
					<tr>
						<th style="width: 1px"><input type="checkbox" data-ckb="all"></th>
						<th>招商标题</th>
						<th>供应商名称</th>
						<th>品牌中文名</th>
						<th>门店</th>
						<th>状态</th>
						<th>招商人</th>
						<th>创建日期</th>
					</tr>
				</thead>
				<tbody>
					<c:forEach items="${page.list}" var="sb" varStatus="i">
						<tr
							data-herf="${contextPath}/biz/brand/brandPositionLog/${sb.id}/view?navId=${navId}"
							data-target="_self">
							<td class="o-l-tab-ckb"><input type="checkbox"
								<c:if test="${sb.status =='20'||sb.status =='00'}"> disabled="disabled" 	</c:if>
								value="${sb.id}" index="${i.index }" name="checke"
								data-ckb-id="${sb.id}"></td>
							<td title="${sb.title}"><div
									STYLE="width: 120px; overflow: hidden; text-overflow: ellipsis">
									<nobr>${sb.title} </nobr>
								</div> <label id="title_lab${i.index}" style="display: none;">${sb.title}</label></td>
							<td>${sb.supplier.cname}<label
								id="supplierCname_lab${i.index}" style="display: none;">${sb.supplier.cname}</label></td>
							<td>${sb.baseBrand.brandCname}<label
								id="brandCname_lab${i.index}" style="display: none;">${sb.baseBrand.brandCname}</label></td>
							<td>${sb.shop.name}<label id="shopName_lab${i.index}" style="display: none;">${sb.shop.name}</label></td>
							<td><ossp:value dictType="brandPositionLog"
									key="${sb.status}"></ossp:value> <label
								id="status_lab${i.index}" style="display: none;">${sb.status}</label></td>
							<td>${sb.brandPos._createName}</td>
							<td><fmt:formatDate value="${sb.createTime}" pattern="yyyy-MM-dd" /></td>
						</tr>
					</c:forEach>
				</tbody>
			</table>
		</div>
		<pager:pager pageSize="${page.pageSize}" pageNo="${page.pageNo}"
			url="" total="${page.total}" />
		<script type="text/javascript" src="${staticPath}/js/list.js"></script>
	</form:form>
	<div class="modal fade" id="contractTypeMoadl" tabindex="-1"
		role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content">
				<!-- /modal-header -->
				<div class="modal-body">
					<table class="table">
						<tr>
							<form:form id="form" method="get"></form:form>
							<td>
								<div class="col-sm-12">
									<label for="brandAttribute_lab" class="col-sm-5 control-label">合同类型</label>
									<div class="col-sm-8 f_6">
										<ossp:select dictType="CONTRACT_TYPE" name="type"
											id="type" onchange="showDiv()">
										</ossp:select>
									</div>
								</div>
							</td>
						</tr>
						<tr>
							<td>
								<div class="col-sm-8" id="mainContractNoDiv" style="display: none;">
									<label for="brandAttribute_lab" class="col-sm-3 control-label">主合同号</label>
									<input type="text" class="f_5" name="mainContractNo" id="mainContractNo" style="width: 200px;">
								</div>
							</td>
						</tr>
					</table>

				</div>
				<!-- /modal-body -->
				<div class="modal-footer">
					<button type="button" id="ok_btn" class="btn btn-primary"
						onclick="brandAdd()">确定</button>
					<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
				</div>
				<!-- /modal-footer -->
			</div>
		</div>
	</div>
</body>
</html>